package cn.wolfcode.crm.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.github.pagehelper.PageInfo;

import cn.wolfcode.crm.domain.CustomerTraceHistory;
import cn.wolfcode.crm.domain.SystemDictionaryItem;
import cn.wolfcode.crm.query.CustomerTraceHistoryQueryObject;
import cn.wolfcode.crm.query.SystemDictionaryItemQueryObject;
import cn.wolfcode.crm.service.ICustomerTraceHistoryService;
import cn.wolfcode.crm.service.ISystemDictionaryItemService;

@Controller
@RequestMapping("/customerTraceHistory")
public class CustomerTraceHistoryController {
	@Autowired
	private ICustomerTraceHistoryService customerTraceHistoryService;
	
	@Autowired
	private ISystemDictionaryItemService systemDictionaryItemService;

	@RequestMapping("/list")
	public String list(@ModelAttribute("qo") CustomerTraceHistoryQueryObject qo, Model model) {
		PageInfo<CustomerTraceHistory> pageInfo = customerTraceHistoryService.list(qo);

		SystemDictionaryItemQueryObject qo1 = new SystemDictionaryItemQueryObject();
		qo1.setParentId(3L);	//交流方式
		List<SystemDictionaryItem> types = systemDictionaryItemService.listNotPage(qo1);
		
		model.addAttribute("types", types);
		
		model.addAttribute("pageInfo", pageInfo);
		return "customerTraceHistory/list";
	}

	@RequestMapping("/saveOrUpdate")
	public String saveOrUpdate(CustomerTraceHistory entity) {
		customerTraceHistoryService.saveOrUpdate(entity);
		return "redirect:/customerTraceHistory/list.do";
	}
}
